import { intersection } from "lodash";
import { useEffect } from "react";
// 高阶组件
// 入参：基础组件
// 返回值：包装后的基础组件
function withAuthControl(Component, permissions) {
    const permissions_state = ["view", "delete", "create", "edit"];
    const hasPermission = !!intersection(permissions, permissions_state).length;
    function Wrapper() {
        return hasPermission ? (
            <Component></Component>
        ) : (
            "你暂时没有查看该页面权限"
        );
    }
    return Wrapper;
}
function App() {
    useEffect(() => {
        console.log("我去请求接口了");
    }, []);
    return (
        <div>
            <div>我是VIP页面啊</div>
        </div>
    );
}
export default withAuthControl(App, ["hahaha"]);
